home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / Sample Code / Snippets / QuickTime / Easy Video Grabber / EasyGrabberTest.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-15  |  1.8 KB  |  116 lines  |  [TEXT/KAHL]

  1. /* file: EasyGrabberTest.c
  2.   *
  3.   * Started 18 December 1991
  4.   *
  5.   * An example of the simplest
  6.   * interface to a video digitizer.
  7.   *
  8.   */
  9.  
  10.  
  11. /*--------------------------
  12.     Inclusions
  13. --------------------------*/
  14.  
  15. /*
  16.  * There's a lot, because we
  17.  * need to INIT all the managers.
  18.  */
  19.  
  20. #include <QuickDraw.h>
  21. #include <Events.h>
  22. #include <Menus.h>
  23. #include <ToolUtils.h>
  24. #include <Menus.h>
  25. #include <Windows.h>
  26. #include <Memory.h>
  27. #include <Fonts.h>
  28. #include <OSEvents.h>
  29.  
  30. #include <Movies.h>
  31.  
  32. #include "BigEasyVideoGrabber.h"
  33.  
  34.  
  35. /*--------------------------
  36.     Local Prototypes
  37. --------------------------*/
  38.  
  39. static void InitToolbox(void);
  40. static void DigitizeInAWindow(void);
  41.  
  42. void main(void);
  43.  
  44. /*--------------------------
  45.     The Computer Program
  46. --------------------------*/
  47.  
  48. void InitToolbox(void)
  49.     {
  50.     InitGraf(&qd.thePort);
  51.     InitFonts();
  52.     FlushEvents(0xffff,0);
  53.     InitWindows();
  54.     InitMenus();
  55.     InitCursor();
  56.  
  57.     EnterMovies();
  58.     }
  59.  
  60. void DigitizeInAWindow(void)
  61.     {
  62.     WindowPtr w;
  63.     Rect r;
  64.     short i;
  65.     Boolean gotAFrame;
  66.  
  67.     SetRect(&r,100,100,260,220);        /* 160 x 120 window */
  68.     
  69.     w = NewCWindow(0,&r,"\pFive Clicks",true,
  70.             noGrowDocProc,
  71.             (WindowPtr)-1,0,0);
  72.  
  73.     SetPort(w);
  74.  
  75.     /*
  76.      * Set the rectangle we'll be drawing into.
  77.      */
  78.     SetRect(&r,0,0,160,120);
  79.  
  80.     /*
  81.      * Let the user click five times
  82.      * and grab a frame each time.
  83.      *
  84.      * This is a substandard user interface,
  85.      * I am sure you will agree.
  86.      */
  87.     for(i = 0; i < 5; i++)
  88.         {
  89.         /*
  90.          * Wait For A MouseClick
  91.          */
  92.         while(!Button());
  93.         while(Button());
  94.  
  95.         /*
  96.          * Grab a frame, allocate and deallocate on the fly.
  97.          */
  98.         gotAFrame = GrabEasyVideoGrabber(nil,&r);
  99.  
  100.         /*
  101.          * If we didn't get a frame, just quit and go home.
  102.          */
  103.         if(!gotAFrame)
  104.             return;
  105.         }
  106.     }
  107.  
  108. void main(void)
  109.     {
  110.     InitToolbox();
  111.     DigitizeInAWindow();
  112.     FlushEvents(0xffff,0);
  113.     }
  114.  
  115.  
  116.